Skip to content

Add CrewAI instrumentation#4860

Closed
srinjoy356 wants to merge 3 commits into
open-telemetry:mainfrom
srinjoy356:add-crewai-instrumentation
Closed

Add CrewAI instrumentation#4860
srinjoy356 wants to merge 3 commits into
open-telemetry:mainfrom
srinjoy356:add-crewai-instrumentation

Conversation

@srinjoy356

Copy link
Copy Markdown

Description

Adds a new instrumentation package for CrewAI (multi-agent LLM orchestration),
built on opentelemetry-util-genai. Also includes a small fix to
ToolInvocation._apply_finish in the util itself — tool_result was set as a
field but never surfaced onto the span, and non-primitive values (dicts,
etc.) for arguments/tool_result crashed span attribute validation since they
weren't JSON-encoded. Both needed for this instrumentation's tool spans to
actually carry a result.

Addresses the gap described in SigNoz/signoz#11663 (opened in a different
repo, so not linked as a closing keyword there).

Fixes #4859

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

  • 17 unit tests against an in-memory span exporter (span names, attributes,
    exception handling, handoff-link logic, and two concurrency tests for
    overlapping/back-to-back LLM calls on a shared instance).
  • Full end-to-end run against a real SigNoz instance and real OpenAI calls,
    confirming the actual span hierarchy and a real handoff link.
  • ruff check/format and pyright --strict both clean.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Adds a new instrumentation package for CrewAI, built on
opentelemetry-util-genai per the GenAI instrumentation review rules:
invoke_workflow/invoke_agent/chat/execute_tool spans via TelemetryHandler,
agent-to-agent handoffs as span links rather than parent-child spans, and
all six of CrewAI's independent LLM call paths patched.

Also fixes ToolInvocation._apply_finish in opentelemetry-util-genai itself:
tool_result was set as a field but never serialized onto the span, and
arguments/tool_result were passed through as raw Python values instead of
JSON-encoded, which crashes span attribute validation for non-primitive
values. Both needed for this instrumentation's tool spans to actually carry
a result.

Fixes open-telemetry#4859

Assisted-by: Claude Sonnet 5
@linux-foundation-easycla

linux-foundation-easycla Bot commented Jul 23, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

Assisted-by: Claude Sonnet 5
@github-actions github-actions Bot added the gen-ai Related to generative AI label Jul 23, 2026
@srinjoy356
srinjoy356 marked this pull request as ready for review July 23, 2026 15:05
@srinjoy356
srinjoy356 requested a review from a team as a code owner July 23, 2026 15:05
@xrmx

xrmx commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for your work but the genai work has been moved to the genai-python repository, the new instrumentations are tracked in this issue open-telemetry/opentelemetry-python-genai#141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gen-ai Related to generative AI

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

New instrumentation: CrewAI

5 participants